package cn.hiapi.shopkeeper.entity.activity;

import cn.hiapi.basic.entity.BasicEntity;
import cn.hiapi.basic.serializer.LongToStringSerializer;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * @author AdinZ
 * @date 2022/12/12 22:14
 */
@Entity
@Table(name = "hiapi_shopkeeper_activity_spike")
@ApiModel(description = "秒杀活动")
@Getter
@Setter
public class ActivitySpike extends BasicEntity {
    @Id
    @GeneratedValue(generator = "snowflake")
    @GenericGenerator(name = "snowflake", strategy = "cn.hiapi.basic.id.SnowflakeId")
    @JSONField(serializeUsing = LongToStringSerializer.class)
    private Long id;

    @ApiModelProperty("活动id")
    private long aid;
    @ApiModelProperty("店铺id")
    private long shopId;
    @ApiModelProperty("商品名称")
    private String title;
    @ApiModelProperty("商品介绍")
    @Column(columnDefinition = "text")
    private String body;

    @ApiModelProperty("限购数量")
    private Integer limitNum;
    @ApiModelProperty("库存数量")
    private int stockNum;
    @ApiModelProperty("秒杀价格")
    @Column(columnDefinition = "decimal(10,2)")
    private BigDecimal price = BigDecimal.ZERO;
    @ApiModelProperty("创建时间")
    private long created = System.currentTimeMillis();
    @ApiModelProperty("更新时间")
    private long updated = System.currentTimeMillis();
}
